package com.zy.drug.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zy.drug.mapper.DrugInfoMapper;
import com.zy.drug.pojo.DrugInfo;
import com.zy.drug.pojo.DrugInfoExcelVo;
import com.zy.drug.service.DrugInfoService;
import com.zy.drug.vo.ReqVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author Administrator
* @description 针对表【t_drug_info】的数据库操作Service实现
* @createDate 2025-03-23 15:41:39
*/
@Service
public class DrugInfoServiceImpl implements DrugInfoService {

    @Autowired
    private DrugInfoMapper drugInfoMapper;
    @Override
    public int saveBatch(ArrayList list) {
       return  drugInfoMapper.saveBatch(list);
    }

    @Override
    public PageInfo<DrugInfo> queryForPage(ReqVo reqVo) {
        int pageSize = reqVo.getPageSize();
        int pageNum =reqVo.getPageNum();
        String drugName =reqVo.getDrugName();
        String pinyin =reqVo.getPinyin();
        PageHelper.startPage(pageNum, pageSize);
        List<DrugInfo> list = drugInfoMapper.selectByCondition(pinyin,drugName);
        return new PageInfo<>(list);
    }

    @Override
    public void saveBatchVo(List<DrugInfoExcelVo> cachedDataList) {
        drugInfoMapper.saveBatchVo(cachedDataList);
    }
}
